package com.example.a2105_ivideo.umengAnalazyTest

import android.os.Bundle
import android.view.View
import android.view.ViewStub
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import com.example.a2105_ivideo.R
import com.umeng.analytics.MobclickAgent


class UmengActivity : AppCompatActivity() {
    private lateinit var view_stub: ViewStub
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_umeng)
        view_stub = findViewById(R.id.view_stub)

        //初始化操作放在异步中
//        Thread.sleep(2000)

    }

    override fun onResume() {
        super.onResume()
        MobclickAgent.onPageStart("UmengActivity")
        //渲染
        view_stub.inflate()

    }

    override fun onPause() {
        super.onPause()
        MobclickAgent.onPageEnd("UmengActivity")
    }

    fun login(view: View) {
        //当用户使用自有账号登录时，可以这样统计：
        MobclickAgent.onProfileSignIn("yaotianxue")
        //上报用户属性
        MobclickAgent.userProfileMobile("13387538888")
        MobclickAgent.userProfileEMail("developer@gmail.com")
        MobclickAgent.userProfile("key111", "val111")
        MobclickAgent.userProfile("key222", 123457878L)
        MobclickAgent.userProfile("key333", 0.0234 as Double)
    }
    fun logout(view: View) {
        //登出
        MobclickAgent.onProfileSignOff();
    }
    //测试点击事件次数
    fun textEvent(view: View) {
        val music: MutableMap<String, Any> = HashMap()
        music["music_type"] = "popular" //自定义参数：音乐类型，值：流行
        music["singer"] = "JJ" //歌手：(林俊杰)JJ
        music["song_name"] = "A_Thousand_Years_Later" //歌名：一千年以后
        music["song_price"] = 100 //价格：100元
        UmengUploadUtil.uploadMineTabClick(this, music)
    }
}